package com.xx.ems.service.impl;

import java.util.Map;

import org.springframework.stereotype.Service;

import com.xx.ems.model.Users;
import com.xx.ems.service.EquipmentReceiveService;
import com.xx.ems.system.BaseService;

@Service(value="equipmentReceiveService")
public class EquipmentReceiveServiceImpl extends BaseService implements EquipmentReceiveService {
	@Override
	public boolean receiveEquipment(String eidArray, int uid, Users user) {
		try{
			getTransaction().begin();
			getEquipmentReceiveDao().receiveEquipment(eidArray.split(","), uid, user);
			getTransaction().commit();
			return true;
		}catch (Exception e) {
			e.printStackTrace();
			getTransaction().rollback();
			return false;
		}
	}
	
	@Override
	public boolean restoreEquipment(String eidArray, Users user) {
		try{
			getTransaction().begin();
			getEquipmentReceiveDao().restoreEquipment(eidArray.split(","), user);
			getTransaction().commit();
			return true;
		}catch (Exception e) {
			e.printStackTrace();
			getTransaction().rollback();
			return false;
		}
	}
	public int getTotalpage() {
		return getTotalpage();
	}
	@Override
	public Map<String, Object> getReceiveNumList(int pageNow, int maxCount) {
		return getEquipmentReceiveDao().getReceiveNumList(pageNow, maxCount);
	}

	@Override
	public Map<String, Object> getReceiveByReceiveNumId(int rid, int pageNow, int maxCount) {
		return getEquipmentReceiveDao().getReceiveByReceiveNumId(rid, pageNow, maxCount);
	}
}